package num168;

/**
 * 168. Excel表列名称
 * 题目：https://leetcode-cn.com/problems/excel-sheet-column-title
 * 三叶姐题解: https://leetcode-cn.com/problems/excel-sheet-column-title/solution/gong-shui-san-xie-cong-1-kai-shi-de-26-j-g2ur/
 * 三叶姐
 */
class Solution {
    public String convertToTitle(int cn) {
        StringBuilder sb = new StringBuilder();
        while (cn > 0) {
            cn--;
            sb.append((char) (cn % 26 + 'A'));
            cn /= 26;
        }
        sb.reverse();
        return sb.toString();
    }
}
